package com.yunhe.controller;

import com.yunhe.entity.Menu;
import com.yunhe.service.MenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * 控制层代码
 * 调用业务层代码
 */
@RestController
@RequestMapping("/menu")
@Api(value = "/menu",description = "菜单信息管理")
public class MenuController {
    @Autowired
    MenuService menuService;

    /**
     * 这种方法，需要借助于postman来测试，没有对接前端/
     * @param roleId
     * @return
     */
    @GetMapping("/list")
    @ApiOperation("获取所有菜单列表")
    public List<Menu> list(
            @ApiParam(value = "角色编号",required = true)
            @RequestParam String roleId){
        List<Menu> menuList = menuService.lambdaQuery().like(Menu::getMenuright, roleId).list();
        return menuList;
    }

    /**
     * 路径处理，可以在页面测试
     * @param roleId
     * @return
     */
    @GetMapping("/list/{roleId}")
    @ApiOperation("查询某个角色id的菜单")
    public List<Menu> list2(@PathVariable String roleId){
        List<Menu> menuList = menuService.lambdaQuery().like(Menu::getMenuright, roleId).list();
        return menuList;
    }
}